/**
 * @description 
 * @author cq
 * @Date 2021-04-07 17:46:55
 * @LastEditTime 2021-04-07 18:22:26
 * @LastEditors cq
 */
function logger({ dispatch, getState }) {
  return next => action => {
    // next 就是层传进来的dispatch
    // action 就是要执行的动作
    console.log(`next`, next)
    console.log("action", action)
    console.log("++++++++++++++++++++++++++"); 

    console.log(action.type + "执行了！！！"); 

    const prevState = getState();
    console.log("prev state", prevState); 

    // todo  执行玩新的dispatch在拿getState就是最新的值了
    const returnValue = next(action);

    const nextState = getState();
    console.log("cur state", nextState); 

    console.log("++++++++++++++++++++++++++"); 

    return returnValue;
  };
}

export default logger